package com.example.webflux_module.service;

import com.example.webflux_module.entity.Customer;
import com.example.webflux_module.repository.CustomerRepository;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
public class CustomerService {
    private final CustomerRepository repository;

    public CustomerService(CustomerRepository repository) {
        this.repository = repository;
    }

    public Flux<Customer> getAllCustomers() {
        return repository.findAll();
    }

    public Mono<Customer> getCustomerById(Long id) {
        return repository.findById(id);
    }

    public Mono<Customer> createCustomer(Customer customer) {
        return repository.save(customer);
    }

    // Update and delete methods...
}